import Vue from 'vue'
import store from '@/store/index'
export const routerKey = {
  autoReply: '自动回复',
  index: '首页'
}
export function reportHandle(from, to) {
  let list = to.path.split('/')
  const obj = {
    value: '',
    label: []
  }
  list = list.filter(item => item !== '')
  list.map(item => {
    obj.value += item + '-'
    obj.label.push(routerKey[item] || '暂未定义')
  })
  console.log(obj, 'obj')
  obj.value = obj.value.slice(0, obj.value.length - 1)
  if (store?.state?.user?.token && from.fullPath !== '/') {
    if (Vue.prototype.$AccessReport) {
      Vue.prototype.$AccessReport.report(obj.value, obj.label)
    }
  } else {
    console.log('token不存在')
  }
}